/*  
 *  Copyright RobOtter (2008) 
 * 
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/** \file hcontrol_system.c
  *
  * Implement the low level robot control system
  */

#include "hcontrol_system.h"

#ifndef NULL
#define NULL ((void*)0)
#endif

void hcs_init(hcontrol_system *hcs)
{
  hcs->hrs = NULL;
  hcs->hpm = NULL;

  hcs->consign = (vxya_t){0.0,0.0,0.0};
}

void hcs_set_related_hposition_manager(hcontrol_system *hcs,
                                  hposition_manager *hpm)
{
  uint8_t flags;

  IRQ_LOCK(flags);
  hcs->hpm = hpm;
  IRQ_UNLOCK(flags);
}

void hcs_set_related_hrobot_system(hcontrol_system *hcs,
                                 hrobot_system *hrs)
{
  uint8_t flags;

  IRQ_LOCK(flags);
  hcs->hrs = hrs;
  IRQ_UNLOCK(flags);
}

void hcs_update(void *data)
{
  uint8_t flags;
  hcontrol_system *hcs;
  
  hcs = (hcontrol_system*)data;

  // TODO

}

void hcs_set_consign(hcontrol_system *hcs, double x, double y, double a){
  uint8_t flags;

  IRQ_LOCK(flags);
  hcs->consign.x = x;
  hcs->consign.y = y;
  hcs->consign.a = a;
  IRQ_UNLOCK(flags);
}
